package org.demo.szml.eventtype.event.logging;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.demo.szml.eventtype.event.BaseEvent;
import org.demo.szml.eventtype.router.logging.LoggingEventRouter;

import java.io.Serializable;
import java.util.Date;

/**
 * @description: 日志消息事件
 * @date: 2025/6/16 11:07
 * @version: 1.0
 */
public class LoggingEvent extends BaseEvent<LoggingEvent.LoggingEventInfo> {

    private static final String topic = LoggingEventRouter.LOGGING_EVENT_TOPIC;


    @Override
    public EventMessage<LoggingEventInfo> buildEventMessage(LoggingEventInfo data) {
        return new EventMessage<>(this.topic(), new Date(), data);
    }

    @Override
    public String topic() {
        return topic;
    }

    /**
     * @description: 日志事件类型
     * @date: 2025/6/15 23:00
     * @version: 1.0
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class LoggingEventInfo implements Serializable {
        private static final long serialVersionUID = 1L;

        // 用户ID
        private Long userId;

        // 操作类型
        private String action;

        // IP地址
        private String ip;

        // 详细信息
        private String detail;

        // 日志唯一ID 通过此ID保证幂等性
        private Long logId;

        // 日志标志码 由此码看是否处理操作过程中出现异常
        private Integer statusCode;
    }


}
